package net.hn.hnms.biz.plan.request;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 生产成本计划执行信息
 *
 * @author ly
 * @since 1.0.0 2022-08-16
 */
@Data
@ApiModel("生产成本计划执行信息")
public class ExecutionCostReq{

	/**
	* 主键ID
	*/
	@ApiModelProperty(value = "id")
	private String costExecutionId;

	/**
	* 矿编码
	*/
	@ApiModelProperty(value = "煤矿编号")
	private String mineCode;

	/**
	* 日期
	*/
	@NotNull(message = "请选择日期")
	@JsonFormat(
			pattern = "yyyy-MM-dd",
            timezone = "GMT+8"
	)
	@ApiModelProperty(value = "日期")
	private Date executionDate;

	@ApiModelProperty(value = "月份")
	private Integer month;

	/**
	* 材料消耗(万元)
	*/
	@ApiModelProperty(value = "材料消耗(万元)")
	@Digits(integer = 9, fraction=2, message = "材料消耗格式不正确")
	@DecimalMin(value = "0.00", message = "材料消耗格式不正确")
	private BigDecimal costMaterial;

	/**
	* 修旧利废(万元)
	*/
	@ApiModelProperty(value = "修旧利废(万元)")
	@Digits(integer = 9, fraction=2, message = "修旧利废格式不正确")
	@DecimalMin(value = "0.00", message = "修旧利废格式不正确")
	private BigDecimal costRecycle;

	/**
	* 生活/生产用水(万元)
	*/
	@ApiModelProperty(value = "生活/生产用水(万元)")
	@Digits(integer = 9, fraction=2, message = "生活/生产用水格式不正确")
	@DecimalMin(value = "0.00", message = "生活/生产用水格式不正确")
	private BigDecimal costWater;

	/**
	* 电费(万元)
	*/
	@ApiModelProperty(value = "电费(万元)")
	@Digits(integer = 9, fraction=2, message = "电费格式不正确")
	@DecimalMin(value = "0.00", message = "电费格式不正确")
	private BigDecimal costPower;

	public Date getBeginDate() {
		if (month != null) {
			return DateUtil.beginOfMonth(DateUtil.offsetMonth(DateUtil.beginOfYear(new Date()), month - 1));
		}
		return null;
	}

	public Date getEndDate() {
		if (month != null) {
			return DateUtil.endOfMonth(DateUtil.offsetMonth(DateUtil.beginOfYear(new Date()), month - 1));
		}
		return null;
	}


	@ApiModelProperty(value = "公司编号")
	private String companyCode;


	@ApiModelProperty(value = "煤矿名称")
	private String mineName;

	@ApiModelProperty(value = "公司名称")
	private String companyName;

}